CC=g++
CFLAGS=-Wall -std=c++0x

DIR=AR
BIN=Bin
OBJ=Obj
LIBS=Obj/log.o Obj/authr.o Obj/nsr.o Obj/utf8.o Obj/us-client*.o Obj/ns-client*.o Obj/an-client*.o
CSOURCE=$(DIR)/authorization.cpp $(DIR)/ar.rpc_clnt.c $(DIR)/ar.rpc_xdr.c
SSOURCE=$(DIR)/authorizationsrv.cpp $(DIR)/ar.rpc_svc.c $(DIR)/ar.rpc_xdr.c $(DIR)/ar.rpc.srv.cpp
HEADERS=$(DIR)/ar.rpc.h

all: client server test

client: $(CSOURCE) $(HEADERS) $(DIR)/authorization.h 
	$(CC) $(CFLAGS) -c -o $(OBJ)/ar-client-xdr.o $(DIR)/ar.rpc_xdr.c
	$(CC) $(CFLAGS) -c -o $(OBJ)/ar-client-rpc.o $(DIR)/ar.rpc_clnt.c
	$(CC) $(CFLAGS) -c -o $(OBJ)/ar-client.o $(DIR)/authorization.cpp

server: $(SSOURCE) $(HEADERS) $(DIR)/authorizationsrv.h 
	$(CC) $(CFLAGS) $(LIBS) -o $(BIN)/ar-server $(SSOURCE)

test: 
	$(CC) $(CFLAGS) -o $(BIN)/ar-test $(LIBS) $(OBJ)/config.o $(OBJ)/ar-client*.o $(DIR)/test.cpp 
